/**
 * 
 */
package com.bolbachchan.common.ui;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Chaitanya
 * 
 */
public class DefaultScreenMessageContainer implements ScreenMessageContainer {

    private List<ScreenMessage> messages;

    /**
     * 
     */
    public DefaultScreenMessageContainer() {

    }

    /*
     * (non-Javadoc)
     * @see com.bolbachchan.common.ui.ScreenMessageContainer#getMessages()
     */
    @Override
    public List<ScreenMessage> getMessages() {
	if (messages == null) {
	    messages = new ArrayList<ScreenMessage>();
	}
	return messages;
    }

    /*
     * (non-Javadoc)
     * @see
     * com.bolbachchan.common.ui.ScreenMessageContainer#setMessages(java.util
     * .List)
     */
    @Override
    public void setMessages(List<ScreenMessage> messages) {
	this.messages = messages;
    }

    /*
     * (non-Javadoc)
     * @see
     * com.bolbachchan.common.ui.ScreenMessageContainer#addMessage(com.bolbachchan
     * .common.ui.ScreenMessage)
     */
    @Override
    public void addMessage(ScreenMessage message) {
	getMessages().add(message);
    }

    /*
     * (non-Javadoc)
     * @see
     * com.bolbachchan.common.ui.ScreenMessageContainer#addAllMessages(java.
     * util.List)
     */
    @Override
    public void addAllMessages(List<ScreenMessage> messages) {
	getMessages().addAll(messages);
    }

}
